import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@general/constants'
import { preferences } from '@general/preferences';
import { useAccessStore, useUserStore } from '@general/stores'
import { startProgress, stopProgress } from '@general/utils';
import type { Router } from 'vue-router'



/**
 * 通用守卫配置
 * @param router
 */
function setupCommonGuard(router: Router) {
    // 记录已经加载的页面
    const loadedPaths = new Set<String>();
    router.beforeEach(async (to) => {
        to.meta.loaded = loadedPaths.has(to.path);

        // 页面加载进度条
        if (!to.meta.loaded && preferences.transition.progress) {
            startProgress();

        }
        return true
    })
    router.afterEach((to) => {
        // 记录已经加载的页面，后续的页面切换动画等效果不在重复执行
        loadedPaths.add(to.path)
        // 关闭页面加载进度条
        if (preferences.transition.progress) {
            stopProgress();
        }
    })

}

/**
 * 权限访问守卫配置
 * @param router
 */

function setupAccessGuard(router: Router) {
    router.beforeEach(async (to, from) => {
        const accessStore = useAccessStore();
        const userStore = useUserStore();
        const authStore = useAuth
    })
}